home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / UTIL / Alpha 6.5.sit / Help / Debugging < prev    next >
Text File  |  1994-08-03  |  2KB  |  76 lines

  1. 5.0 introduces the Tcl function-tracing command 'traceFunc'. traceFunc 
  2. allows you to trace a specfic function whenever it is called, sending the 
  3. output to another window. The indented trace of the function includes all 
  4. parameters, each argument enclosed within single quotes, as well as the 
  5. function result. 
  6.  
  7. The syntax of the function is:
  8.  
  9. traceFunc on <funcName> <winName>
  10. traceFunc off
  11. traceFunc status
  12.  
  13.  
  14. For example, if I want to trace the proc 'nextFunc' (defined in 
  15. procs.tcl), the following might be a log of my activity at the Tcl shell:
  16.  
  17. Welcome to Alpha's Tcl shell.
  18. Alpha> traceFunc on nextFunc traceWin
  19. Alpha> traceFunc status
  20. Func-tracing on, func: nextFunc, win: traceWin
  21. Alpha> 
  22.  
  23. Now I create a new window, "dirty" it so that I can get a save dialog, 
  24. and save it as 'traceWin'. Note that tracing is only sent to open 
  25. windows, so I must leave 'traceWin' open.
  26.  
  27. Then I open any random non-C file (because I want the function to fail), go 
  28. to the beginning of the file, and type escape-x 'nextFunc'.  The output 
  29. should look something like the following:
  30.  
  31. nextFunc 
  32.  searchFunc '1' 
  33.   getPos 
  34.   OK: 38530
  35.   select '38530' 
  36.   OK: 
  37.   saveVars 
  38.   OK: 
  39.   if '(1==1)' '
  40.         nextLine
  41.     ' 'else' '
  42.         previousLine
  43.     ' 
  44.    nextLine 
  45.    OK: 
  46.   OK: 
  47.   getPos 
  48.   OK: 38573
  49.   set 'pos' '38573' 
  50.   OK: 38573
  51.   setVar 'regExpr' '1' 
  52.   OK: 
  53.   setVar 'forward' '1' 
  54.   OK: 
  55.   setVar 'ignoreCase' '1' 
  56.   OK: 
  57.   search '^[^ ¥t¥(#¥r/@].*¥(.*¥)$' '38573' 
  58.   ERROR: Search unsuccessful
  59.  ERROR: Search unsuccessful
  60. ERROR: Search unsuccessful
  61.  
  62.  
  63. The trace output shows that the problem was an unsuccessful search. In 
  64. this case, a dialog informed us of this fact anyway, but many Alpha 
  65. routines are not as friendly when it comes to error messages.
  66.  
  67.  
  68. Another way to debug Tcl routines is to insert statements that print 
  69. values to another window. For example, one could use the following 
  70. routine: 
  71.  
  72. proc out args {
  73.     insertText -w "*tcl shell*" $args
  74. }
  75.  
  76.